<?php

namespace App\Policies;

use App\Models\User;
use App\Models\Topic;

class TopicPolicy extends Policy
{
    /**
     * 当话题关联作者的 ID 等于当前登录用户 ID 时候才授权修改
     */
    public function update(User $user, Topic $topic)
    {
         return $user -> isAuthorOf($topic);
    }

    /**
     * 只允许作者删除话题
     */
    public function destroy(User $user, Topic $topic)
    {
        return $user -> isAuthorOf($topic);
    }
}
